home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / 422mods.zip / GOOSEIV.422 < prev    next >
Text File  |  1993-02-27  |  21KB  |  483 lines

  1. Enhanced Message Quote Mod for WWIV 4.22   (QUOTE324.MOD)
  2. Goose #1 @17310
  3. Thursday, February 25, 1993   8:06 pm
  4.                    Enhanced Message Quoting Mod v3.24           (QUOTE324.MOD)
  5.                              for WWIV 4.22
  6.                       by Goose, 1@17310 (WWIVlink)
  7.  
  8. Once again, it's time for an update to the Quote Mod.  This version is again
  9. WWIV 4.22 specific, since it uses the routine Wayne has built into the code
  10. for 4.22.  But, added are colorized quotes (from v3.21 of the mod), and
  11. initials in quote (v3.22 of the mod), and the correction of initial guessing
  12. for WWIV 4.22 and FIDO gated messages (v3.23 of the mod).
  13.  
  14. Thanks to Wafwot, 113@2050 (I'm not sure what system he runs) for the base
  15. code for the initials.  I changed it a little and integrated it with the rest
  16. of the mod here.  And thanks to Hellfire #1 @13600 for the fixes for v3.23 of
  17. the mod.
  18.  
  19. This is a new version of the mod, which is specifically for WWIV 4.22 (and
  20. I'm assuming later versions).  This mod relies on the quote support that Wayne
  21. built in, which unfortuntely only works with external editors that support the
  22. QUOTES.IND file.  Once you've installed this, you'll have the familiar Ctrl-P
  23. Ctrl-Q for any external editor or /QUOTE for the internal editor back.  But,
  24. to make sure you see it, I'll leave in the following paragraph:
  25.  
  26.  == NOTE == NOTE == NOTE == NOTE == NOTE == NOTE == NOTE == NOTE == NOTE ==
  27.  =                                                                        =
  28.  =  To quote using this version, you will either type "/QUOTE" in the     =
  29.  =  internal editor, or use Ctrl-P Ctrl-Q in any external editor.  You    =
  30.  =  will then be shown the message, and asked which lines to quote,       =
  31.  =  rather than being told to delete unneeded lines.  Hopefully this      =
  32.  =  will get rid of some of the abuses of the older version of the mod..  =
  33.  =                                                                        =
  34.  =  Also, be sure you understand the comments in the get_quote part in    =
  35.  =  EXTRN.C for getting it set up correctly with the external editors     =
  36.  =  you have installed.                                                   =
  37.  =                                                                        =
  38.  == NOTE == NOTE == NOTE == NOTE == NOTE == NOTE == NOTE == NOTE == NOTE ==
  39.  
  40. Before I start with the mod though, the first change is to FSED's CONSOLE.CFG
  41. file (assuming you have FSED installed as an available editor.  If not, ignore
  42. this paragraph).  You will need to add the following line to enable the redraw
  43. function locally (I actually copied many of the commands from the WORDSTAR.CFG
  44. file to make the commands locally and remotely the same, in addition to the
  45. special local functions).
  46.  
  47. C 28    "^B"                            # repaint screen
  48.  
  49. =============================================================================
  50.  
  51. Many BBS software programs these days offer a "quoting" feature when replying
  52. messages, which provides a "> " at the beginning of each quoted line, plus
  53. provides the quoted text after it.  For example, you would see a message like:
  54.  
  55. ------------------------------------------------------------------------------
  56.  
  57. > How can I get rid of the DGROUP error in WWIV?  I've been modding my board
  58. > and now I get that whenever I recompile.
  59.  
  60. A DGROUP error means that you've run of out variable space in the board.....
  61.  
  62. ------------------------------------------------------------------------------
  63.  
  64. Finally, in WWIV 4.21a, Wayne Bell added limited quoting support.  The text of
  65. the message is written to the file QUOTES.TXT, and the "indented" form written
  66. to QUOTES.IND.  But the external editor doesn't use the quote function, and
  67. the only external editor that supports it is WWIVedit.  Not to say that
  68. WWIVedit isn't a good editor, since it's the one I use all the time, but not
  69. every can use it, and some people do prefer others.  So, if you got used to
  70. these functions with earlier versions of WWIV with the old quote mod, here's
  71. your chance to get them back.
  72.  
  73. OK, now for the first part of the mod.  Load up FCNS.H and make the following
  74. addition for void get_quote:
  75.  
  76. int full_external(char *s, int ctc, int ccc);
  77. char *create_chain_file(char *fn);
  78. void get_quote(int fsed);                                  /* mod - add */
  79.  
  80. Save FCNS.H and load VARS.H, and add the following variable declarations:
  81.  
  82. /****************************************************************************/
  83.  
  84. __EXTRN__ int bquote,equote,quoting;                       /* mod - add */
  85.  
  86. __EXTRN__ char ansistr[81], cdir[81], charbuffer[161], chatreason[81],
  87.                crttype, curspeed[81], dc[81], dcd[81], dszlog[81],
  88.  
  89. /****************************************************************************/
  90.  
  91. Then load up EXTRN.C, and make the following changes at the top of
  92. unsigned char getkeyext() to intercept the keys in the external editor:
  93.  
  94.   if (holding) {
  95.     holding=0;
  96.     return(held);
  97.   }
  98.   ch=getkey();
  99.   if ((charbufferpointer==0) && (bquote==0)) {             /* mod - change */
  100.     if (ch==16) {
  101.       ch=getkey();
  102.       if ((ch==17) && (charbufferpointer==0) &&            /* mod - add */
  103.         (quotes_ind!=NULL)) {                              /* mod - add */
  104.         get_quote(1);                                      /* mod - add */
  105.  
  106.     /*  change the following lines based on the setup  */
  107.     /*  for your external editors.  The numbers in the */
  108.     /*  case statement should be the control code for  */
  109.     /*  the screen redraw command.  For example, FSED  */
  110.     /*  uses Ctrl-B, which is the second letter of the */
  111.     /*  alphabet, which means you need a 2 for the     */
  112.     /*  return code.  Known editors are:               */
  113.     /*                                                 */
  114.     /*  Editor             Key            Code         */
  115.     /*  ------            ------          ----         */
  116.     /*  FSED              Ctrl-B            2          */
  117.     /*  FEDIT             Ctrl-R           18          */
  118.     /*  ZARFF             Ctrl-E            5          */
  119.     /*  ED                Ctrl-L           12          */
  120.     /*  WWIVEDIT          Ctrl-R           18          */
  121.     /*                                                 */
  122.     /*  Don't forget to change this to match whatever  */
  123.     /*  your editor setup is.                          */
  124.     /*                                                 */
  125.     /*  Note:  The quote mod currently does not work   */
  126.     /*  with ZARFF (also known as ZEDIT) because it    */
  127.     /*  seems to bypass WWIV's interrupt processing.   */
  128.     /*  Sorry, but there's nothing I can do to fix     */
  129.     /*  that one, but it should work fine with any of  */
  130.     /*  the others.                                    */
  131.  
  132.         switch (thisuser.defed) {                          /* mod - add */
  133.           case 1 :                                         /* mod - add */
  134.             ch=2;                                          /* mod - add */
  135.             break;                                         /* mod - add */
  136.           case 2 :                                         /* mod - add */
  137.             ch=18;                                         /* mod - add */
  138.             break;                                         /* mod - add */
  139.           case 3 :                                         /* mod - add */
  140.             ch=5;                                          /* mod - add */
  141.             break;                                         /* mod - add */
  142.           case 4 :                                         /* mod - add */
  143.             ch=12;                                         /* mod - add */
  144.             break;                                         /* mod - add */
  145.           case 5 :                                         /* mod - add */
  146.             ch=18;                                         /* mod - add */
  147.             break;                                         /* mod - add */
  148.           default :                                        /* mod - add */
  149.             ch=0;                                          /* mod - add */
  150.             break;                                         /* mod - add */
  151.         }                                                  /* mod - add */
  152.         return(ch);                                        /* mod - add */
  153.       }                                                    /* mod - add */
  154.       if ((ch==1) && (charbufferpointer==0)) {
  155.         strcpy(charbuffer,&(thisuser.macros[2][0]));
  156.  
  157. Scroll down to void far interrupt newintr1(...), and add the following two
  158. lines near the top of the void:
  159.  
  160.   ni_ch=ni_r.h.ah;
  161.   ni_ch1=0;
  162.  
  163.   if (quoting)                                             /* mod - add */
  164.     ni_ch=0;                                               /* mod - add */
  165.   switch(ni_ch) {
  166.     case 0x01:
  167.       NEW_STK();
  168.  
  169. Then at the bottom of the file, read in the following code to handle the
  170. quoting of the message:
  171.  
  172. void get_quote(int fsed)                         /* mod - add entire void */
  173. {
  174.   static char s[141];
  175.   static int i,i1,i2,abort,next,rl;
  176.   static int l1,l2;
  177.  
  178.   quoting=fsed;
  179.   rl=1;
  180.   do {
  181.     if (fsed)
  182.       outstr("\x0c");
  183.     if (rl) {
  184.         i=1; l1=l2=0; abort=0; next=0;
  185.       do {
  186.         if (quotes_ind[l2++]==10)
  187.           l1++;
  188.       } while ((l2<quotes_ind_l) && (l1<2));
  189.       do {
  190.         itoa(i++,s,10);
  191.         osan(s,&abort,&next);
  192.         if (irt_name[0]) {
  193.           s[0]=32;
  194.           i1=1;
  195.         } else
  196.           i1=0;
  197.         if (abort) {
  198.           do {
  199.             l2++;
  200.           } while ((quotes_ind[l2]!=13) && (l2<quotes_ind_l));
  201.         } else {
  202.           do {
  203.             s[i1++]=quotes_ind[l2++];
  204.           } while ((quotes_ind[l2]!=13) && (l2<quotes_ind_l));
  205.         }
  206.         if (quotes_ind[l2]) {
  207.           l2+=2;
  208.           s[i1]=0;
  209.         }
  210.         pla(s,&abort);
  211.       } while (l2<quotes_ind_l);
  212.       --i;
  213.     }
  214.     nl();
  215.     i1=0; i2=0; s[0]=0;
  216.     while (!s[0]) {
  217.       sprintf(s,"Quote from line 1-%d? (?=relist,Q=quit) ",i);
  218.       prt(2,s);
  219.       input(s,3);
  220.     }
  221.     if (s[0]=='Q')
  222.       rl=0;
  223.     else if (s[0]!='?') {
  224.       i1=atoi(s);
  225.       if (i1==i)
  226.         i2=i1;
  227.       else {
  228.         s[0]=0;
  229.         while (!s[0]) {
  230.           sprintf(s,"through line %d-%d? (Q=quit) ",i1,i);
  231.           prt(2,s);
  232.           input(s,3);
  233.         }
  234.         if (s[0]=='Q')
  235.           rl=0;
  236.         else if (s[0]!='?')
  237.           i2=atoi(s);
  238.       }
  239.     }
  240.     if (i2) {
  241.       sprintf(s,"Quote line(s) %d-%d? ",i1,i2);
  242.       prt(5,s);
  243.       if (!ny())
  244.         i2=0;
  245.     }
  246.   } while ((!abort) && (!hangup) && (rl) && (!i2));
  247.   quoting=0;
  248.   charbufferpointer=0;
  249.   if ((i1>0) && (i2>=i1) && (i2<=i) && (rl)) {
  250.     bquote=i1;
  251.     equote=i2;
  252.   }
  253. }
  254.  
  255. Save EXTRN.C and load up COM.C.  Find int empty() and make the following
  256. change:
  257.  
  258. int empty()
  259. {
  260.   if (kbhitb() || (incom && (head != tail)) ||
  261.       (charbufferpointer && charbuffer[charbufferpointer]) ||
  262.       (in_extern == 2) || (bquote))                        /* mod - change */
  263.     return(0);
  264.   return(1);
  265. }
  266.  
  267. Then make the following changes in char inkey() to allow the quote to be read
  268. in to the current message:
  269.  
  270.   char ch=0;
  271.  
  272.   static int qpointer=0,cpointer;                          /* mod - add */
  273.                                                            /* mod - add */
  274.   if (bquote) {                                            /* mod - add */
  275.     if (!qpointer) {                                       /* mod - add */
  276.       charbuffer[1]=48;                                    /* mod - add */
  277.       charbuffer[2]=13;                                    /* mod - add */
  278.       charbuffer[3]=0;                                     /* mod - add */
  279.       cpointer=0;                                          /* mod - add */
  280.       qpointer=1;                                          /* mod - add */
  281.       while (qpointer<bquote+2) {                          /* mod - add */
  282.         if (quotes_ind[cpointer++]==10)                    /* mod - add */
  283.           ++qpointer;                                      /* mod - add */
  284.       }                                                    /* mod - add */
  285.       charbufferpointer=1;                                 /* mod - add */
  286.     }                                                      /* mod - add */
  287.     if (quotes_ind[cpointer]==10) {                        /* mod - add */
  288.       ++qpointer;                                          /* mod - add */
  289.       if (qpointer>equote+2) {                             /* mod - add */
  290.         qpointer=0; bquote=0; equote=0;                    /* mod - add */
  291.         return(16);                                        /* mod - add */
  292.       } else                                               /* mod - add */
  293.         ++cpointer;                                        /* mod - add */
  294.     }                                                      /* mod - add */
  295.     if (quotes_ind[cpointer]==3) {                         /* mod - add */
  296.       ++cpointer;                                          /* mod - add */
  297.       return(16);                                          /* mod - add */
  298.     }                                                      /* mod - add */
  299.     if (quotes_ind[cpointer]==0) {                         /* mod - add */
  300.       qpointer=0; bquote=0; equote=0;                      /* mod - add */
  301.       return(13);                                          /* mod - add */
  302.     }                                                      /* mod - add */
  303.     return(quotes_ind[cpointer++]);                        /* mod - add */
  304.   }                                                        /* mod - add */
  305.  
  306.   if (x_only)
  307.     return(0);
  308.  
  309.   if (charbufferpointer) {
  310.     if (!charbuffer[charbufferpointer])
  311.       charbufferpointer = charbuffer[0] = 0;
  312.     else {                                                 /* mod - change */
  313.       if ((charbuffer[charbufferpointer])==3)              /* mod - add */
  314.         charbuffer[charbufferpointer]=16;                  /* mod - add */
  315.       return(charbuffer[charbufferpointer++]);
  316.     }                                                      /* mod - add */
  317.   }
  318.  
  319. Then load XINIT.C, and add the following code to initialize the quote
  320. variables in void init(...):
  321.  
  322.   sysop_alert=0;
  323.   global_handle=0;
  324.   bquote=0;                                                /* mod - add */
  325.   equote=0;                                                /* mod - add */
  326.   quoting=0;                                               /* mod - add */
  327.  
  328. Save XINIT.C and load MSGBASE.C.  Scroll down to void inmsg(...), and add the
  329. following lines:
  330.  
  331.       if (s[0]=='/') {
  332.         if (stricmp(s,"/HELP")==0) {
  333.           savel=0;
  334.           printmenu(2);
  335.         }
  336.         if (stricmp(s,"/QUOTE")==0) {                      /* mod - add */
  337.           savel=0;                                         /* mod - add */
  338.           if (quotes_ind!=NULL)                            /* mod - add */
  339.             get_quote(0);                                  /* mod - add */
  340.         }                                                  /* mod - add */
  341.         if (stricmp(s,"/LI")==0) {
  342.           savel=0;
  343.  
  344. Save MSGBASE.C and load MSGBASE1.C.  Now, we get to make some changes to
  345. Wayne's quote routines for 4.22.  These allow you to easily change the color
  346. of the prompt character, preserve the color of the quoted text, and make it a
  347. little better at flowing the text (but still far from perfect).  Note that the
  348. PFXCOL variable is the color of the '>' used to designate a quote, which can
  349. be changed to any WWIV color you want.  The remainder of the text is displayed
  350. in whatever color the original message was in, which makes sense to me, but it
  351. wouldn't be too hard to change that either...  if it seemed to be worth the
  352. trouble.  Scroll down near the end of the file and make the following changes:
  353.  
  354. #define LINELEN 79
  355. #define SAVE_IN_MEM                                        /* mod - add */
  356. #define PFXCOL 2                                           /* mod - add */
  357. #define QUOTECOL 0                                         /* mod - add */
  358.  
  359. /* mod - add the define for WRTPFX, and replace the defines for NL and FLSH */
  360.  
  361. #define WRTPFX {fprintf(f,"\003%c",PFXCOL+48);if (tf==1)\
  362.                 cp=fwrite(pfx,1,pfxlen-1,f); else cp=fwrite(pfx,1,pfxlen,f);\
  363.                 fprintf(f,"\003%c",cc);}
  364. #define NL {if (!cp) {fprintf(f,"\003%c",PFXCOL+48);fwrite(pfx,1,pfxlen,f);}\
  365.             if (ctlc) fwrite("0",1,1,f);fwrite("\r\n",1,2,f);cp=ns=ctlc=0;}
  366. #define FLSH {if (ss1) {if (cp && (l3+cp>=linelen)) NL else if (ns)\
  367.               cp+=fwrite(" ",1,1,f);if (!cp) {if (ctld)\
  368.               fprintf(f,"\004%c",ctld);ctld=0; WRTPFX; } fwrite(ss1,1,l2,f);\
  369.               cp+=l3;ss1=NULL;l2=l3=0;ns=1;}}
  370.  
  371. int brtnm;                                                 /* mod - add */
  372.  
  373. int ste(int i)                              /* mod - add entire void */
  374. {
  375.  
  376. if ((irt_name[i]==32) && (irt_name[i+1]=='O') && (irt_name[i+2]=='F') &&
  377.     (irt_name[i+3]==32))
  378.   if (irt_name[i+4]>47 && irt_name[i+4]<58)
  379.     return(0);
  380. if (irt_name[i]==96)
  381.    brtnm++;
  382.  
  383. return(1);
  384. }
  385.  
  386. char *quoteinitials(void)                   /* mod - add entire void */
  387. {
  388.   static char qi[8];
  389.   int i,i1;
  390.  
  391.   brtnm=0;
  392.  
  393.   if (irt_name[0]==96)
  394.    qi[0]=irt_name[2];
  395.   else
  396.    qi[0]=irt_name[0];
  397.  
  398.   i1=1;
  399.   for (i=1; i<strlen(irt_name) && (i1<6) && (irt_name[i]!='#') && ste(i) &&
  400.      brtnm!=2; i++)
  401.    if ((irt_name[i]==32) && (irt_name[i+1]!='#') && (irt_name[i+1]!=96))
  402.       qi[i1++]=irt_name[i+1];
  403.   qi[i1]=0;
  404.   strcat(qi,"> ");
  405.   return(qi);
  406. }
  407.  
  408. void grab_quotes(messagerec *m, char *aux)
  409. {
  410.   char *ss,*ss1;
  411.   long l,l1,l2,l3;
  412.   FILE *f;
  413.   char *pfx=quoteinitials();                               /* mod - change */
  414.   int cp=0,ctla=0,ctlc=0,ns=0,ctld=0,ff;
  415.   int pfxlen=strlen(pfx);                                  /* mod - change */
  416.   char cc=QUOTECOL+48;                                     /* mod - add */
  417.   int linelen=LINELEN,tf=0;                                /* mod - add */
  418.   long lp;                                                 /* mod - add */
  419.  
  420.   /* mod - delete pfx=get_stringx(1,102); */
  421.   /* mod - delete pfxlen=strlen(pfx);     */
  422.  
  423.   unlink("quotes.txt");
  424.   unlink("quotes.ind");
  425.  
  426. And a little farther down:
  427.  
  428.             case '\n':
  429.               tf=0;                                        /* mod - add */
  430.               if (ctla) {
  431.                 ctla=0;
  432.               } else {
  433.                 cc=QUOTECOL+48;                            /* mod - add */
  434.                 FLSH;
  435.                 NL;
  436.               }
  437.               break;
  438.             case ' ':
  439.             case '\r':
  440.               if (ss1) {
  441.                 FLSH;
  442.               } else {
  443.                 if (ss[l1]==' ') {
  444.                   if (cp+1>=linelen)                       /* mod - change */
  445.                     NL;
  446.                   if (!cp) {
  447.                     if (ctld)
  448.                       fprintf(f,"\x4%c",ctld);
  449.                     ctld=0;
  450.                     WRTPFX;                                /* mod - change */
  451.                   }
  452.                   cp++;
  453.                   fwrite(" ",1,1,f);
  454.                 }
  455.               }
  456.               break;
  457.             default:
  458.               if (!ss1)
  459.                 ss1=ss+l1;
  460.               l2++;
  461.               if (ctlc) {                                  /* mod - change */
  462.                 if (ss[l1]==48)                            /* mod - add */
  463.                   ss[l1]=QUOTECOL+48;                      /* mod - add */
  464.                 cc=ss[l1];                                 /* mod - add */
  465.                 ctlc=0;
  466.               } else {                                     /* mod - change */
  467.                 l3++;
  468.                 if (!tf) {                                 /* mod - add */
  469.                   if (ss[l1]=='>') {                       /* mod - add */
  470.                     tf=1;                                  /* mod - add */
  471.                     linelen=LINELEN;                       /* mod - add */
  472.                   } else {                                 /* mod - add */
  473.                     tf=2;                                  /* mod - add */
  474.                     linelen=LINELEN-5;                     /* mod - add */
  475.                   }                                        /* mod - add */
  476.                 }                                          /* mod - add */
  477.               }                                            /* mod - add */
  478.               break;
  479.  
  480. That's it for the source code changes, at least for this version.  Just update
  481. the menus to reflect the changes, and recompile the entire board (since FCNS.H
  482. has changed).
  483.